/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie.ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import movie.entity.Film;

/**
 *
 * @author admin
 */
@Stateless
public class EjbFilm {

	@PersistenceContext(unitName = "MoviePU")
	private EntityManager em;

	public List<Film> getListFilm() {
		return em.createNamedQuery("Film.findAll").getResultList();
	}

	// Add business logic below. (Right-click in editor and choose
	// "Insert Code > Add Business Method")
	public void persist(Object object) {
		em.persist(object);
	}

	public void deleteFilm(Integer idFilm) {
		em.remove(em.find(Film.class, idFilm));
	}
}
